#!/system/bin/sh

function get_url_from_tsinghua() {
	LINUX_TXT="清华大学lxc-image仓库"
	LINUX_ZIP=rootfs.tar.xz
	echo "LINUX_TXT: $LINUX_TXT"
	tmp_base_url="https://mirrors.tuna.tsinghua.edu.cn/lxc-images/images/${LINUX_DISTRIBUTION}/${LINUX_ROOTFS_VER}/${CURRENT_VM_ARCH}/default/"
	ndkhttpsget ${tmp_base_url} index.html  2>&1
	httpget_rlt=$?
	if [ $httpget_rlt -ne 0 ]; then
		rm -rf ${app_temp}/index.html
	fi
	cp -f ${app_temp}/index.html ./ 2>/dev/null
	DATETIME_FIELD=
	if [ -f index.html ]; then
		DATETIME_FIELD=$(cat index.html |grep 'title="20'|grep 'href="20'|${ALINKER64} "${tools_dir}/busybox/busybox" awk -v FS="\"" '{print $4}'|${ALINKER64} "${tools_dir}/busybox/busybox" head -c 16) 2>&1
	fi
	LINUX_URL=${tmp_base_url}$DATETIME_FIELD/$LINUX_ZIP
	UNZIP_ARG=-xJf
}





# 清华大学 lxc-image 镜像站点
if [ ! -f $LINUX_ZIP ]; then
    get_url_from_tsinghua
    do_donwload_rootfs
fi
